#!/usr/bin/env python
# @Software: PyCharm
# @Time : 2022/8/4 20:13
# @Author : v_nahuachen
# @Version：V 0.1
# @File : home_page.py
# @desc :
from cases.base import router, base_def


class HomePage(base_def.BaseDef):
    """
    首页相关元素定位及相关操作等
    """

    locator = {
        'app': '/page/view/navigator[1]/button',  # App接口测试
        'page': '/page/view/navigator[2]/button',  # Page接口测试
        'element': '/page/view/navigator[3]/button',  # Element接口测试
        'native': '/page/view/navigator[4]/button',  # Native接口测试
    }

    # 进入不同接口测试
    def interface_page(self, key):
        ele = self.mini.page.get_element(self.locator[key])
        ele.tap()
        ret = False
        if key == 'app':
            ret = self.wait_page(router.appPage)
        elif key == 'page':
            ret = self.wait_page(router.pagePage)
        elif key == 'element':
            ret = self.wait_page(router.elementPage)
        elif key == 'native':
            ret = self.wait_page(router.nativePage)

        return ret
